package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.iview.VipView
import hlhj.fhp.checkpoint.javaBean.MyBaseBean
import hlhj.fhp.checkpoint.javaBean.MyVipBean

/**
 * Created by Never Fear   on 2018\12\14 0014.
Never More....
 */
class VipModule :BaseModule {
    var listener:VipView?=null

    fun getVips(c:Context){
        Apis.myVip()
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<MyVipBean>>(c){
                                override fun httpSuccess(t: Response<MyVipBean>) {
                                    listener?.setMyVip(t.body())
                                }
                            })
                }
    }

    fun bindVIP(num:String,c:Context){
        Apis?.bindVIP(num)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<MyBaseBean>>(c){
                                override fun httpSuccess(t: Response<MyBaseBean>) {
                                    listener?.setBindVip(t.body())
                                }
                            })
                }
    }


}